package com.neulogistics.contrib.procuredcenter.infrastructure.persistence.orm.po;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;

/**
 * 商品表
 * @TableName tb_goods
 */
@TableName(value ="tb_goods", autoResultMap = true)
@Data
public class GoodsPO implements Serializable {
    /**
     * 商品id
     */
    @TableId(value = "goods_id", type = IdType.AUTO)
    private Integer goodsId;

    /**
     * 商品名
     */
    @TableField(value = "goods_name", condition = SqlCondition.LIKE)
    private String goodsName;

    /**
     * 所属二级分类id
     */
    @TableField(value = "set_id")
    private Integer setId;

    /**
     * 计量单位
     */
    @TableField(value = "measure_unit")
    private String measureUnit;

    /**
     * 商品原价
     */
    @TableField(value = "goods_price")
    private Integer goodsPrice;

    /**
     * 商品折扣：75折:75；88折:88
     */
    @TableField(value = "goods_discount")
    private Integer goodsDiscount;

    /**
     * 商品成本
     */
    @TableField(value = "goods_cost")
    private Integer goodsCost;

    /**
     * 商品型号
     */
    @TableField(value = "goods_model", condition = SqlCondition.LIKE)
    private String goodsModel;

    /**
     * {供应商id、供应商名称}
     */
    @TableField(value = "vendor_info", typeHandler = JacksonTypeHandler.class)
    private JSONObject vendorInfo;

    /**
     * 商品保质期限
     */
    @TableField(value = "goods_shelf_life")
    private Date goodsShelfLife;

    /**
     * 可否退货：0:不可；1:可
     */
    @TableField(value = "opt_return")
    private Integer optReturn;

    /**
     * 可否换货：0:不可；1:可
     */
    @TableField(value = "opt_replace")
    private Integer optReplace;

    /**
     * 商品备注信息
     */
    @TableField(value = "goods_remark")
    private String goodsRemark;

    /**
     * 是否删除
     */
    @TableField(value = "deleted")
    @TableLogic(value = "0", delval = "1")
    private Integer deleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        GoodsPO other = (GoodsPO) that;
        return (this.getGoodsId() == null ? other.getGoodsId() == null : this.getGoodsId().equals(other.getGoodsId()))
            && (this.getGoodsName() == null ? other.getGoodsName() == null : this.getGoodsName().equals(other.getGoodsName()))
            && (this.getSetId() == null ? other.getSetId() == null : this.getSetId().equals(other.getSetId()))
            && (this.getMeasureUnit() == null ? other.getMeasureUnit() == null : this.getMeasureUnit().equals(other.getMeasureUnit()))
            && (this.getGoodsPrice() == null ? other.getGoodsPrice() == null : this.getGoodsPrice().equals(other.getGoodsPrice()))
            && (this.getGoodsDiscount() == null ? other.getGoodsDiscount() == null : this.getGoodsDiscount().equals(other.getGoodsDiscount()))
            && (this.getGoodsCost() == null ? other.getGoodsCost() == null : this.getGoodsCost().equals(other.getGoodsCost()))
            && (this.getGoodsModel() == null ? other.getGoodsModel() == null : this.getGoodsModel().equals(other.getGoodsModel()))
            && (this.getVendorInfo() == null ? other.getVendorInfo() == null : this.getVendorInfo().equals(other.getVendorInfo()))
            && (this.getGoodsShelfLife() == null ? other.getGoodsShelfLife() == null : this.getGoodsShelfLife().equals(other.getGoodsShelfLife()))
            && (this.getOptReturn() == null ? other.getOptReturn() == null : this.getOptReturn().equals(other.getOptReturn()))
            && (this.getOptReplace() == null ? other.getOptReplace() == null : this.getOptReplace().equals(other.getOptReplace()))
            && (this.getGoodsRemark() == null ? other.getGoodsRemark() == null : this.getGoodsRemark().equals(other.getGoodsRemark()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getGoodsId() == null) ? 0 : getGoodsId().hashCode());
        result = prime * result + ((getGoodsName() == null) ? 0 : getGoodsName().hashCode());
        result = prime * result + ((getSetId() == null) ? 0 : getSetId().hashCode());
        result = prime * result + ((getMeasureUnit() == null) ? 0 : getMeasureUnit().hashCode());
        result = prime * result + ((getGoodsPrice() == null) ? 0 : getGoodsPrice().hashCode());
        result = prime * result + ((getGoodsDiscount() == null) ? 0 : getGoodsDiscount().hashCode());
        result = prime * result + ((getGoodsCost() == null) ? 0 : getGoodsCost().hashCode());
        result = prime * result + ((getGoodsModel() == null) ? 0 : getGoodsModel().hashCode());
        result = prime * result + ((getVendorInfo() == null) ? 0 : getVendorInfo().hashCode());
        result = prime * result + ((getGoodsShelfLife() == null) ? 0 : getGoodsShelfLife().hashCode());
        result = prime * result + ((getOptReturn() == null) ? 0 : getOptReturn().hashCode());
        result = prime * result + ((getOptReplace() == null) ? 0 : getOptReplace().hashCode());
        result = prime * result + ((getGoodsRemark() == null) ? 0 : getGoodsRemark().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", goodsId=").append(goodsId);
        sb.append(", goodsName=").append(goodsName);
        sb.append(", setId=").append(setId);
        sb.append(", measureUnit=").append(measureUnit);
        sb.append(", goodsPrice=").append(goodsPrice);
        sb.append(", goodsDiscount=").append(goodsDiscount);
        sb.append(", goodsCost=").append(goodsCost);
        sb.append(", goodsModel=").append(goodsModel);
        sb.append(", vendorInfo=").append(vendorInfo);
        sb.append(", goodsShelfLife=").append(goodsShelfLife);
        sb.append(", optReturn=").append(optReturn);
        sb.append(", optReplace=").append(optReplace);
        sb.append(", goodsRemark=").append(goodsRemark);
        sb.append(", deleted=").append(deleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}